package org.groupg.practice.text;

import org.apache.commons.text.StringSubstitutor;
import org.apache.commons.text.lookup.StringLookup;

import java.time.LocalDate;
import java.util.function.Function;

public class StringSubstitutorAdvancedExample {
    public static void main(String[] args) {
        String template = "Today is ${date}.";

        Function<String, String> dateFunction = key -> LocalDate.now().toString();

        StringSubstitutor substitutor = new StringSubstitutor((StringLookup) dateFunction);

        String result = substitutor.replace(template);

        System.out.println(result);
    }
}